package ee.videorentalstore.filmsrentedbyusers;

import java.util.ArrayList;
import java.util.List;
import ee.videorentalstore.users.User;

public class FilmsRentedByUsersManager 
{
	private static FilmsRentedByUsersManager instance = null;
	private List<FilmRentedByUser> listOfFilmsRentedByUsers = new ArrayList<FilmRentedByUser>();

	
	private FilmsRentedByUsersManager()
	{
		
	}
	
	
	public static FilmsRentedByUsersManager getInstance()
	{
		if (instance == null)
		{
			instance = new FilmsRentedByUsersManager();
		}
		return instance;
	}
	
	
	public void addFilmRentedByUser(FilmRentedByUser filmRentedByUser)
	{
		listOfFilmsRentedByUsers.add(filmRentedByUser);
	}
	
	
	public List<FilmRentedByUser> getListOfAllFilmsRentedByUser(User user)
	{
		List<FilmRentedByUser> listOfAllFilmsRentedByUser = new ArrayList<FilmRentedByUser>();
		for (FilmRentedByUser filmRentedByUser : listOfFilmsRentedByUsers)
		{
			if (filmRentedByUser.getUser().equals(user))
			{
				listOfAllFilmsRentedByUser.add(filmRentedByUser);
			}
		}
		return listOfAllFilmsRentedByUser;
	}
}
